//
//  TestView.m
//  回调Block
//
//  Created by clz on 2019/7/30.
//  Copyright © 2019年 clz. All rights reserved.
//

#import "TestView.h"

@implementation TestView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.backgroundColor=[UIColor redColor];
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"点我" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:18];
        button.frame = CGRectMake(0, 0, 300, 50);
        
        [self addSubview:button];
        
    }
    return self;
}

- (void)buttonAction:(UIButton *)sender{
    NSLog(@"触发");
//    self.changeColor(@"函数传过来的参数");
    
    if (self.changeValueBlock) {
        self.changeValueBlock();
    }
    
}

//- (void)userBlock:(void(^)(NSString *str))block{
//    self.changeColor = block;
//}

- (void)userBlock:(TestBlock)testBlock{
    self.changeColor = testBlock;
}

@end
